<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="demo-form-inline">
      <el-form-item label="ID" prop="userId">
        <el-input v-model="queryParams.userId" placeholder="id" />
      </el-form-item>
      <el-form-item label="开始日期" prop="startTime">
        <el-date-picker v-model="queryParams.startTime" type="datetime" placeholder="选择开始日期"
          value-format="yyyy-MM-dd HH:mm:ss" />
      </el-form-item>
      <el-form-item label="结束日期" prop="endTime">
        <el-date-picker v-model="queryParams.endTime" type="datetime" placeholder="选择结束日期"
          value-format="yyyy-MM-dd HH:mm:ss" />
      </el-form-item>
      <el-form-item label="排序" prop="orderBy">
        <el-select v-model="queryParams.orderBy" placeholder="请选择">
          <el-option v-for="(item, index) in statusOptions" :key="index" :label="item.label" :value="item.id" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row>
      <el-table-column align="center" label="序号" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="用户ID" align="center" prop="userId" />

      <el-table-column label="订单号" align="center" prop="orderNo" />
      <el-table-column label="是否管理员赠送" align="center" prop="orderNo">
        <template slot-scope="scope">
          {{ scope.row.isAdminGive == 1 ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column label="产品ID	" align="center" prop="productId" />
      <el-table-column label="是否管理员赠送	" align="center" prop="productId">
        <template slot-scope="scope">
          {{ scope.row.isAdminGive==0?'否':'是' }}
        </template>
      </el-table-column>
      <el-table-column label="累计总收益		" align="center" prop="totalRevenue" />
      <el-table-column label="剩余待发放金额		" align="center" prop="residueAmount" />
      <el-table-column label="创建时间		" align="center" prop="createTime" />
      <el-table-column label="托管中总额" align="center" prop="totalAmount" />
      <el-table-column label="状态		" align="center" prop="type	">
        <template slot-scope="scope">
          {{ setTypeTxt(scope.row.status) }}
        </template>
      </el-table-column>

      <!-- <el-table-column label="操作" align="center">
       <template slot-scope="scope">
         <el-button type="text" @click="handleShowInfo(scope.row)">详情</el-button>

       </template>
     </el-table-column> -->
    </el-table>
    <div class="pagination">
      <el-pagination :current-page.sync="queryParams.pageNum" :page-sizes="[10, 20, 30, 40]"
        :page-size.sync="queryParams.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"
        @size-change="fetchData" @current-change="fetchData" />
    </div>
  </div>
</template>

<script>
import { dividendList } from '@/api/table'
export default {
  components: {

  },
  data() {
    return {
      list: null,
      listLoading: true,
      total: 0,
      typeOptions: [
        { label: '虚拟货币', value: 'usdt' },
        { label: '人民币', value: 'rmb' }
      ],
      statusOptions: [
        { id: 'processingTotal', label: '托管中总额' },
        { id: 'residueTotal', label: '剩余待发放金额' }

      ],
      queryParams: {

        userId: '',
        pageNum: 1,
        pageSize: 10,
        type: '',
        startTime: '',
        endTime: '',
        orderDirection: 'DESC',
        orderBy: ''
      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      dividendList(this.queryParams).then(response => {
        this.list = response.data.records
        this.listLoading = false
        this.total = response.data.total
      })
    },
    handleShowInfo(e) {
      this.$refs.showInfo.show(e)
    },
    setStateTxt(index) {
      let str = ''
      switch (Number(index)) {
        case 1:
          str = '审核中'
          break
        case 2:
          str = '已完成'
          break
        case 3:
          str = '失败'
          break
      }
      return str
    },
    setTypeTxt(index) {
      let str = ''
      switch (index) {
        case 'progressing':
          str = '进行中'
          break
        case 'end':
          str = '已结束'
          break
      }
      return str
    },
    onSubmit() {
      this.queryParams.page = 1
      this.fetchData()
    },
    reset() {
      this.queryParams = {

        hash: '',

        pageNum: 1,
        pageSize: 10,
        status: ''
      }
      this.fetchData()
    },
    handleAdd() {
      this.$refs.add.show()
    },
    handleEdit(e) {
      this.$refs.add.edit(e)
    },
    handleDel(e) {
      this.$confirm('此操作将删除公告, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        communityDelete(e).then(res => {
          this.fetchData()
          this.$message({
            type: 'success',
            message: '成功!'
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        })
      })
    }
  }
}
</script>
